#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
import os
from kconfiglib import Kconfig
from menuconfig import menuconfig

def mconf_set_env():
    """
    Set Kconfig Env
    """
    os.environ["MENUCONFIG_STYLE"] = "default   path=fg:black,bg:white \
                                                separator=fg:white,bg:yellow,bold \
                                                selection=fg:white,bg:blue,bold help=path"
    os.environ["KCONFIG_CONFIG"] = os.path.join("../.config")
    os.environ["KCONFIG_CONFIG_HEADER"] = "# Generated by MiniWebServer Kconfig\n"
    os.environ["KCONFIG_AUTOHEADER"] = os.path.join("../src/configs/autoconfig.h")
    os.environ["CONFIG_"] = ""

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    mconf_set_env()
    kconf = Kconfig(filename="../Kconfig")
    menuconfig(kconf)
    kconf.write_autoconf()
